package com.polaris.live.net.service

import com.polaris.live.common.cacha.UserManager
import com.polaris.live.common.network.ApiResponse
import com.polaris.live.im.sfs.bean.chat.GreetMessage
import com.polaris.live.resp.back_resp.luckybag.LuckyBagDetailResp
import com.polaris.live.resp.back_resp.luckybag.LuckyBagMessageResp
import com.polaris.live.resp.back_resp.luckybag.LuckyBagMessageStatusResp
import com.polaris.live.resp.back_resp.luckybag.LuckyBagNewResp
import com.polaris.live.resp.back_resp.luckybag.LuckyBagReceiveResp
import com.polaris.live.resp.back_resp.luckybag.LuckyBagSendResp
import com.polaris.live.resp.base.ListResp
import com.polaris.live.resp.go_resp.MessageReadBean
import com.polaris.live.resp.go_resp.UploadGreetBean
import com.polaris.live.resp.go_resp.UserIdBean
import com.polaris.live.resp.go_resp.luckybag.LuckyBagReceiveBean
import com.polaris.live.resp.go_resp.luckybag.LuckyBagSendBean
import com.polaris.live.resp.go_resp.luckybag.LuckyBagSendChatBean
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Query

/**
 * 状态服务
 *
 * @author Created by 长空 on 2023/10/25 11:51
 * @since 1.0.0
 */
interface ChatService {

    /**
     * 获取打招呼列表
     */
    @GET("greet/template/list")
    suspend fun getGreetList(): ApiResponse<List<GreetMessage>>

    /**
     * 上传打招呼模板
     */
    @POST("greet/template")
    suspend fun uploadGreet(@Body uploadGreetBean: UploadGreetBean): ApiResponse<Any>

    /**
     * 修改打招呼模板
     */
    @PUT("greet/template")
    suspend fun putGreet(@Body uploadGreetBean: UploadGreetBean): ApiResponse<Any>

    /**
     * 删除打招呼列表
     */
    @DELETE("greet/template")
    suspend fun deleteGreet(@Query("greetTemplateId") greetTemplateId: Int): ApiResponse<Any>

    /**
     * 消息已读
     */
    @PUT("message/read")
    suspend fun messageRead(@Body messageReadBean: MessageReadBean): ApiResponse<Any>

    /**
     * 福袋消息列表
     */
    @GET("lucky-bag")
    suspend fun getLuckyBagMessages(
        @Query("liveId") liveId: Long?,
        @Query("onlyUncompleted") onlyUncompleted: Boolean,
        @Query("pageNumber") pageNumber: Int,
        @Query("onlyMessage") onlyMessage: Boolean? = null,
    ): ApiResponse<ListResp<LuckyBagMessageResp>>

    /**
     * 福袋消息状态返回
     */
    @GET("lucky-bag/status")
    suspend fun getLuckyBagMessageStatus(@Query("messageIds") messageIds: List<Long>): ApiResponse<List<LuckyBagMessageStatusResp>>

    /**
     * 获取福袋新消息数量
     */
    @GET("lucky-bag/new")
    suspend fun getLuckyBagNewNum(): ApiResponse<LuckyBagNewResp>

    /**
     * 获取福袋可领取的数量
     */
    @GET("lucky-bag/new/receive")
    suspend fun getLuckyBagNewReceive(): ApiResponse<LuckyBagNewResp>

    /**
     * 监听福袋消息
     *
     * 每次调用该接口监听持续30秒，所以客户端需要不断的告知服务端自己还在监听
     */
    @POST("lucky-bag/observe")
    suspend fun observeUserState(@Body request: UserIdBean = UserIdBean(UserManager.getUserId())): ApiResponse<Any>

    /**
     * 获取福袋详情
     */
    @GET("lucky-bag/detail")
    suspend fun luckyBagDetail(@Query("luckyBagId") luckyBagId: Long): ApiResponse<LuckyBagDetailResp>

    /**
     * 获取福袋领取列表
     */
    @GET("lucky-bag/list/receive")
    suspend fun luckyBagReceiveList(@Query("pageNumber") pageNumber: Int): ApiResponse<ListResp<LuckyBagReceiveResp>>

    /**
     * 获取福袋发送列表
     */
    @GET("lucky-bag/list/send")
    suspend fun luckyBagSendList(@Query("pageNumber") pageNumber: Int): ApiResponse<ListResp<LuckyBagSendResp>>

    /**
     * 发送福袋
     */
    @POST("lucky-bag/send")
    suspend fun sendLuckyBag(@Body request: LuckyBagSendBean): ApiResponse<Any>

    /**
     * 领取福袋
     */
    @POST("lucky-bag/receive")
    suspend fun receiveLuckyBag(@Body request: LuckyBagReceiveBean): ApiResponse<LuckyBagDetailResp>

    /**
     * 发送福袋聊天消息
     */
    @POST("lucky-bag/send/message")
    suspend fun sendLuckyBagChat(@Body request: LuckyBagSendChatBean): ApiResponse<Any>

}